package gdconf

import (
	"server_cluster/common/logger"
)

// 抽卡蛋池配置表

type TrailRoleGroupConfig struct {
	Id         int32    `csv:"Id" gorm:"primary_key;autoIncrement:false"` // 试用组id
	RoleIdList IntArray `csv:"RoleId,omitempty"`                          // 角色id list
}

func (c *TrailRoleGroupConfig) TableName() string {
	return "config_trail_role_group"
}

func (g *GameDataConfig) saveTrailRoleGroup() {
	saveTableToDb[TrailRoleGroupConfig](g.Db, readTable[TrailRoleGroupConfig](g.CsvPathPrefix+"TrailGroup.csv"))
}
func (g *GameDataConfig) loadTrailRoleGroupConfig() {
	g.GameDataMaps.TrailRoleGroupConfigMap = make(map[int32]*TrailRoleGroupConfig)
	for _, trailRoleGroup := range loadTableFromDb[TrailRoleGroupConfig](g.Db) {
		g.GameDataMaps.TrailRoleGroupConfigMap[trailRoleGroup.Id] = trailRoleGroup
	}
	logger.Info("TrailRoleGroupConfigMap Count: %v", len(g.GameDataMaps.TrailRoleGroupConfigMap))
}

func GetTrailRoleList(groupId int32) []int32 {
	var data, isOk = CONF.GameDataMaps.TrailRoleGroupConfigMap[groupId]
	if !isOk {
		logger.Debug("GetTrailRoleList failed groupId :%v", groupId)
		return nil
	}
	return data.RoleIdList
}
